// Vue.prototype.getNowFormatDate = function() {
//     var date = new Date();
//     var seperator1 = "-";
//     var year = date.getFullYear();
//     var month = date.getMonth() + 1;
//     var strDate = date.getDate();
//     if (month >= 1 && month <= 9) {
//       month = "0" + month;
//     }
//     if (strDate >= 0 && strDate <= 9) {
//       strDate = "0" + strDate;
//     }
//     var currentdate = year + seperator1 + month + seperator1 + strDate;
//     return currentdate;
//   };
exports.install = function (Vue, options) {
 
    // 时间格式化
    Vue.prototype.format_date = function (DateFor){//全局函数1
      let year = DateFor.getFullYear()
      let month = DateFor.getMonth() + 1
      let day = DateFor.getDate()
      if (month >= 1 && month <= 9) {
          month = "0" + month;
      }
      if (day >= 0 && day <= 9) {
          day = "0" + day;
      }
      let tmp= year + '-' + month + '-' + day
      return tmp
    };
 
    // 获取月初，获取 当前月+gap 的月初(若gap为-1，则获取上月初，若gap为1，则获取下月初，
    Vue.prototype.get_month_first = function (gap){
      let date1 = new Date();
      // 获取间隔月
      let gapMonth = date1.getMonth() + gap
      // 获取间隔月月初
      let gapMonthFirstDay=new Date(date1.getFullYear(),gapMonth,1);
      let firstDay = this.format_date(gapMonthFirstDay)
      console.log(firstDay)
      return firstDay
    };
 
    // 获取月末
    Vue.prototype.get_month_last = function (gap){
      // gap = gap + 1
      let date1 = new Date()
      // 获取下个月月初
      let gapMonth = date1.getMonth()
      gapMonth = gapMonth + 1 + gap
 
      let NextMonthFirstDay=new Date(date1.getFullYear(),gapMonth,1)
      NextMonthFirstDay = NextMonthFirstDay.getTime() - 1000*60*60*24
      let temp = new Date()
      temp.setTime(NextMonthFirstDay)
      let lastDay = this.format_date(temp)
      return lastDay
    };
 
    // 获取日期函数，若gap=0,则为系统日期，若不为0，则当期日期-gap(待参考)
    Vue.prototype.get_date = function (gap){
      let date = new Date()
      date = date.getTime() - 1000*60*60*24*gap
      let temp = new Date()
      temp.setTime(date)
      let day = this.format_date(temp)
      return day
    };
 
    // 时间戳转时间
    Vue.prototype.timestamp_to_time = function (gap){
     let year=new Date().getFullYear()
     let month=new Date().getMonth()+1
     let date=new Date().getDate()
     let hour=new Date().getHours()
     let minute=new Date().getMinutes()
     let second=new Date().getSeconds()
     return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; 
      // alert(page)
    };
 
};